package game;

import java.util.Scanner;

public class Shop {
    // 进入商店的方法
    public static void enterShop(Player player, Scanner scanner) {
        System.out.println("欢迎来到商店！当前金币：" + player.gold);
        // 定义商店里的物品，但先不打印出来
        MonsterGame.Item healingItem = new MonsterGame.Item("治疗药水", "healing", 50, 10);
        MonsterGame.Item attackItem = new MonsterGame.Item("攻击药水", "attack", 15, 20);
        MonsterGame.Item defenseItem = new MonsterGame.Item("防御药水", "防御", 10, 15); // 防御药水
        MonsterGame.Item staminaItem = new MonsterGame.Item("体力药水", "体力", 20, 15); // 体力药水
        MonsterGame.Item dodgeItem = new MonsterGame.Item("闪避药水", "闪避", 5, 10);  // 闪避药水
        MonsterGame.Item intelligenceItem = new MonsterGame.Item("智力药水", "智力", 5, 10); // 智力药水
        MonsterGame.Equipment woodSword = new MonsterGame.Equipment("木剑", "Weapon", 10, 0, 10);
        MonsterGame.Equipment leatherArmor = new MonsterGame.Equipment("皮甲", "Armor", 0, 5, 10);
        MonsterGame.Equipment ironSword = new MonsterGame.Equipment("铁剑", "Weapon", 20, 0, 30);
        MonsterGame.Equipment chainmail = new MonsterGame.Equipment("锁子甲", "Armor", 0, 10, 50);
        MonsterGame.Equipment dagger = new MonsterGame.Equipment("匕首", "Weapon", 15, 0, 20);
        MonsterGame.Equipment leatherBoots = new MonsterGame.Equipment("皮靴", "Armor", 0, 3, 15);
        // 以清晰的格式展示商店里的物品
        System.out.println("1. " + woodSword.name + " (" + woodSword.price + " 金币)");
        System.out.println("2. " + leatherArmor.name + " (" + leatherArmor.price + " 金币)");
        System.out.println("3. " + ironSword.name + " (" + ironSword.price + " 金币)");
        System.out.println("4. " + chainmail.name + " (" + chainmail.price + " 金币)");
        System.out.println("5. " + dagger.name + " (" + dagger.price + " 金币)");
        System.out.println("6. " + leatherBoots.name + " (" + leatherBoots.price + " 金币)");
        System.out.println("7. " + healingItem.name + " (" + healingItem.price + " 金币)");
        System.out.println("8. " + attackItem.name + " (" + attackItem.price + " 金币)");
        System.out.println("9. " + defenseItem.name + " (" + defenseItem.price + " 金币)"); // 防御药水
        System.out.println("10. " + staminaItem.name + " (" + staminaItem.price + " 金币)"); // 体力药水
        System.out.println("11. " + dodgeItem.name + " (" + dodgeItem.price + " 金币)"); // 闪避药水
        System.out.println("12. " + intelligenceItem.name + " (" + intelligenceItem.price + " 金币)"); // 智力药水
        System.out.println("请选择你想要购买的物品：");
        int shopChoice = scanner.nextInt();


        if (shopChoice == 1) {
            // 木剑
            if (player.gold >= woodSword.price) {
                player.gold -= woodSword.price;
                player.equip(woodSword);
            } else {
                System.out.println("你的金币不足，无法购买" + woodSword.name + "！");
            }
        } else if (shopChoice == 2) {
            // 皮甲
            if (player.gold >= leatherArmor.price) {
                player.gold -= leatherArmor.price;
                player.equip(leatherArmor);
            } else {
                System.out.println("你的金币不足，无法购买" + leatherArmor.name + "！");
            }
        } else if (shopChoice == 3) {
            // 铁剑
            if (player.gold >= ironSword.price) {
                player.gold -= ironSword.price;
                player.equip(ironSword);
            } else {
                System.out.println("你的金币不足，无法购买" + ironSword.name + "！");
            }
        } else if (shopChoice == 4) {
            // 锁子甲
            if (player.gold >= chainmail.price) {
                player.gold -= chainmail.price;
                player.equip(chainmail);
            } else {
                System.out.println("你的金币不足，无法购买" + chainmail.name + "！");
            }
        } else if (shopChoice == 5) {
            // 匕首
            if (player.gold >= dagger.price) {
                player.gold -= dagger.price;
                player.equip(dagger);
            } else {
                System.out.println("你的金币不足，无法购买" + dagger.name + "！");
            }
        } else if (shopChoice == 6) {
            // 皮靴
            if (player.gold >= leatherBoots.price) {
                player.gold -= leatherBoots.price;
                player.equip(leatherBoots);
            } else {
                System.out.println("你的金币不足，无法购买" + leatherBoots.name + "！");
            }
        } else if (shopChoice == 7) {
            // 治疗药水
            if (player.gold >= healingItem.price) {
                player.gold -= healingItem.price;
                player.addToInventory(healingItem);
            } else {
                System.out.println("你的金币不足，无法购买" + healingItem.name + "！");
            }
        } else if (shopChoice == 8) {
            // 攻击药水
            if (player.gold >= attackItem.price) {
                player.gold -= attackItem.price;
                player.addToInventory(attackItem);
            } else {
                System.out.println("你的金币不足，无法购买" + attackItem.name + "！");
            }
        } else if (shopChoice == 9) {
            // 防御药水
            if (player.gold >= defenseItem.price) {
                player.gold -= defenseItem.price;
                player.addToInventory(defenseItem);
            } else {
                System.out.println("你的金币不足，无法购买" + defenseItem.name + "！");
            }
        } else if (shopChoice == 10) {
            // 体力药水
            if (player.gold >= staminaItem.price) {
                player.gold -= staminaItem.price;
                player.addToInventory(staminaItem);
            } else {
                System.out.println("你的金币不足，无法购买" + staminaItem.name + "！");
            }
        } else if (shopChoice == 11) {
            // 闪避药水
            if (player.gold >= dodgeItem.price) {
                player.gold -= dodgeItem.price;
                player.addToInventory(dodgeItem);
            } else {
                System.out.println("你的金币不足，无法购买" + dodgeItem.name + "！");
            }
        } else if (shopChoice == 12) {
            // 智力药水
            if (player.gold >= intelligenceItem.price) {
                player.gold -= intelligenceItem.price;
                player.addToInventory(intelligenceItem);
            } else {
                System.out.println("你的金币不足，无法购买" + intelligenceItem.name + "！");
            }
        } else {
            System.out.println("无效的商店选择！");
        }
    }

}
